home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / XFORM_RE.JAV < prev   
Encoding:
Text File  |  1996-10-04  |  2.1 KB  |  61 lines

  1.  
  2. package sub_arctic.lib;
  3.  
  4. import java.awt.Rectangle;
  5.  
  6. /** Traversal transformer that takes a Rectangle in parent coordinates and 
  7.  *  transforms it into a child object's coordinates.  The transformed object
  8.  *  must be a Rectangle.
  9.  *  
  10.  *  @see sub_arctic.lib.interactor#traverse_and_collect
  11.  */
  12. public class xform_rect_to_child implements traversal_xform {
  13.   /** Perform the transformation.
  14.    *  
  15.    *  @param Object     parent_parameters a Rectangle object in parent 
  16.    *                                      coordinates.
  17.    *  @param interactor child_obj         the child object. 
  18.    *  @param int        child_indx        the index of that child.
  19.    *  @return a Rectangle at the same position, but expressed in the child's 
  20.    *          coordinates.
  21.    */
  22.   public Object xform(
  23.     Object     parent_parameters, 
  24.     interactor child_obj, 
  25.     int        child_index) 
  26.     {
  27.       Rectangle parent_rect;
  28.  
  29.       if (!(parent_parameters instanceof Rectangle))
  30.     throw new sub_arctic_error("Rectangle object was expected, but not found");
  31.  
  32.       /* extract the parent rectangle */
  33.       parent_rect = (Rectangle)parent_parameters;
  34.  
  35.       /* transform the position into local coordinates of the child */
  36.       return new Rectangle(child_obj.x_into_local(parent_rect.x),
  37.                child_obj.y_into_local(parent_rect.y),
  38.                parent_rect.width, parent_rect.height);
  39.     }
  40.  
  41.    //had:
  42.    //*@exception sub_arctic.exception.bad_value thrown if the parent_parameters 
  43.    //*     parameter is not a Rectangle.
  44. };
  45. /*=========================== COPYRIGHT NOTICE ===========================
  46.  
  47. This file is part of the subArctic user interface toolkit.
  48.  
  49. Copyright (c) 1996 Scott Hudson and Ian Smith
  50. All rights reserved.
  51.  
  52. The subArctic system is freely available for most uses under the terms
  53. and conditions described in 
  54.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  55. and appearing in full in the lib/interactor.java source file.
  56.  
  57. The current release and additional information about this software can be 
  58. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  59.  
  60. ========================================================================*/
  61.